<template>
  <div class="list">
    <!-- <h3>正在抢购&nbsp;&nbsp;&nbsp;上新预告</h3> -->
    <ul class="list1">
        <li v-for="(item1,index1) in arr1" :key='index1' 
        @click="handleClick1(index1);mysort(index1)" :class='{active1:currentIndex1==index1}'
       
        >{{item1}}</li>
     
    </ul>
     <!-- <ul class="list2" >
        <li v-for="(item,index) in arr2" :key="index">{{item}}</li>
       
    </ul> -->

    <div class="list3" v-for="(item,index) in arr"  :key='index'>
        <div class="left">
            <img src="./02.jpg" alt="">
        </div>
        <div class="right">
             <h4>{{item.name}}</h4>
            <p><span class="bbt">⭐️{{item.wjx}}</span>  &nbsp;<span>月售{{item.num}}</span>
         
          <!-- 设置马上抢按钮 -->
            <span class="msq" @click="masq(item)">{{item.lq?'已抢':'马上抢'}}</span>
            </p> 
            <p>
                <span>起送￥{{item.price}}</span>&nbsp;
                <!-- <span>远距离配送￥{{item.psf}}</span>&nbsp; -->
                <span>{{item.min}}分钟</span> &nbsp;
                <span>{{item.juli}}km</span>
            </p>
        </div>
       
    </div>
   

  </div>
</template>

<script>
export default {
 data(){
    return{
        currentIndex1:0,
        masqIndex:0,
      arr:[
        {pic:'./02.jpg',name:'买1送1明星皇堡|用心火烤  肉质紧实  鲜嫩多汁 爆爆团',wjx:'爆爆团价',num:1632,price:25,
        psf:3,yuanjia:6,min:47,juli:3.9,lq:false},
         {pic:'./03.jpg',name:'华莱士 | 聚划算单人套餐 | 进店必选',wjx:'爆爆团价',num:230,price:12.12,
        psf:3.5,yuanjia:4.5,min:44,juli:2.5,lq:false},
         {pic:'./04.jpg',name:'白老大小米果仁酥220g [爆爆团]',wjx:'爆爆团价',num:560,price:20,
        psf:3.5,yuanjia:4.5,min:44,juli:2.9,lq:false}
      ],
      arr1:['正在抢购','上新预告'],
      // arr2:['年贷节热卖','津贴联盟','满减优惠','品质联盟']


    }
 },
 methods:{
    handleClick1(index1){
         this.currentIndex1=index1;
       
    },
    mysort(index1){
        if(index1==0){
              this.arr.sort((a,b)=>{
              return a.num-b.num;
         })
        }else if(index1==1){
            this.arr.sort((a,b)=>{
              return b.price-a.price;
            })
        }else if(index1==2){
             this.arr.sort((a,b)=>{
                return a.juli-b.juli
             })
        }else if(index1==3){
             this.arr.sort((a,b)=>{
                return b.min-a.min
             })
        }
    },
   //  设置马上抢方法
    masq(item){
         item.lq=true;
         // this.masqIndex=index;
    }
 }
}
</script>

<style>
 .list{
    margin: 10px;
 }
 .list1{
    display: flex;
    justify-content: space-around;
 }
 .list2{
    display: flex;
    justify-content: space-around;
    margin: 10px;
 }
 .list2 li{
    background-color:#b6b3b3;
    font-size: 14px;
 }
 .list3{
    margin: 10px;
    display: flex;
 }
  .list3 .left{
    width: 70px;
    height: 70px;
  }
 .list3 .left img{
    width: 70px;
    height: 70px;
    margin: 10px;
 }
   .list3 .right{
     width:100%;
     margin-left: 15px;
     margin-top: 10px;
  }
     .list3 .right p{
    font-size: 10px;

  }
  .active1{
    background-color: red;
  }
 .bbt {
   color: red;
 }
 .msq{
   display: inline-block;
   margin-left: 50px;;
   border: 1px solid red;
   background: red;
    color: white;
    width: 50px;
    text-align: center;
    border-radius: 10px;
 }
</style>